<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@page import="com.webshopping.entry.*"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	request.setAttribute("path", basePath);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>修改商品信息</title>
<script type="text/javascript">
function winLoad(){
	var commoAtt = ${commAttribute};
	commoAttibuteDisplay(commoAtt);
}
//var commoAtt = [{"attValue":"21","attribute":"washerType","commodityId":35},{"attValue":"216","attribute":"washingCapacity","commodityId":35},{"attValue":"221","attribute":"motorType","commodityId":35}];

function commoAttibuteDisplay(commoAtt){
	for(var i=0;i<commoAtt.length;i++){
		var att = commoAtt[i];
		var attEle = document.getElementsByName(att.attribute);
		if(attEle.length==1){
			attEle[0].value = att.attValue;
		}else if(attEle.length>1){
			var attValues = att.attValue.split(",");
			switch(attEle[0].tagName){
			case "INPUT":
				for(var j=0;j<attEle.length;j++){
					for(var k=0;k<attValues.length;k++){
						if(attEle[j].value==attValues[k]){
							attEle[j].checked=true;
						}
					}					
				}
				break;
			}
		}
		
	}	
}
</script>

</head>
<body onload=" winLoad()">
	<form action="<%=path%>/commodity/updateCommodity.do" method="post" target="mainFrame">
		<input type="hidden" name="id" value="${commodity.id} " /> <input
			type="hidden" name="type value=" ${commodity.type} " />
		<table border="1">
			<thead>
				<tr>
					<td colspan="2"><b>基本属性</b></td>
                   
				</tr>
				<tr>
					<td>商品名称</td>
					<td><input type="text" name="name" value="${commodity.name}" /></td>
				</tr>
				<tr>
					<td>商品价格</td>
					<td><input type="text" name="price" value="${commodity.price}" /></td>
				</tr>
				<tr>
					<td>商品价格折扣</td>
					<td><input type="text" name="discount"
						value="${commodity.discount}" /></td>
				</tr>
				<tr>
					<td>商品品牌</td>
					<td><input type="text" name="brand" value="${commodity.brand}" /></td>
				</tr>
				<tr>
					<td>商品颜色</td>
					<td><input type="text" name="color" value="${commodity.color}" /></td>
				</tr>
				<tr>
					<td>商品型号</td>
					<td><input type="text" name="model" value="${commodity.model}" /></td>
				</tr>
				<tr>
					<td>商品数量</td>
					<td><input type="text" name="number" value="${commodity.number}" /></td>
				</tr>
				<tr>
					<td>商品类别</td>
					<td><input type="text" name="type" value="${commodity.type}" /></td>
				</tr>
			</thead>
			<tbody id="imgBody">
				<tr>商品图片
				</tr>
				<tr></tr>
			</tbody>
			<tfoot>
				<tr>
					<td colspan="2"><b>扩展属性</b></td>

				</tr>
				<c:forEach items="${attrList}" var="attr">
					<tr>
						<td colspan="2"><c:out value="${attr}" escapeXml="false"></c:out></td>
					</tr>
				</c:forEach>
				<tr>
					<td><input type="submit" value="更改信息" /></td>
					<td><input type="button" value="重置" /></td>
				</tr>
			</tfoot>
		</table>
	</form>

</body>
</html>